<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_PARENT_ID_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MENU_ITEM_PARENTS_LIST_KEY" />

<c:set var="isInRoot" value="${sessionScope[pageScope.MENU_ITEM_PARENT_ID_KEY] == null}" />

<atleap:isUserInRole roles="core-menuItem-move" var="canMove" />
<atleap:isUserInRole roles="core-menuItem-switchVisibility" var="canSwitchVisibility" />
<atleap:isUserInRole roles="core-menuItem-assignRoles" var="canAssignRoles" />
<atleap:isUserInRole roles="core-menuItem-update" var="canUpdate" />
<atleap:isUserInRole roles="core-menuItem-view" var="canView" />
<atleap:isUserInRole roles="core-menuItem-delete" var="canDelete" />

<c:set var="infoCells" value="4" />
<c:if test="${!isInRoot}">
	<c:set var="infoCells" value="${infoCells+1}" />
</c:if>
<c:set var="constantButtonCells" value="0" />
<c:set var="additionalCells" value="0" />
<c:if test="${!isInRoot && canMove}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${canSwitchVisibility}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${!isInRoot && canAssignRoles}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${!isInRoot && canUpdate}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${canView}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${!isInRoot && canDelete}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>

<c:set var="parentsList" value="${requestScope[pageScope.MENU_ITEM_PARENTS_LIST_KEY]}" />
<c:set var="path" value="" />
<c:set var="multipleDisabled" value="false" />
<c:if test="${parentsList != null}">
	<atleap:iterator items="${parentsList}" var="parentItem" statusVar="listStatus">
		<atleap:fieldValue valueMap="${parentItem.title}" var="titleKey" />
		<atleap:message key="${titleKey}" var="titleMsg" ignore="true" />
		<c:if test="${empty titleMsg}">
			<c:set var="titleMsg" value="${titleKey}" />
		</c:if>
		<c:choose>
			<c:when test="${!listStatus.last}">
				<atleap:rewriteUrl action="/core/menuItem/list"  var="pathElement">
					<atleap:param name="parentItemId" value="${parentItem.id}" />
					<atleap:param name="ownerId" value="${requestScope.ownerId}" />
				</atleap:rewriteUrl>
				<atleap:message key="core.menuItem.form.goToItem" arg0="${titleMsg}" var="linkTitle" />
				<c:set var="pathElement" value="<a href=\"${pathElement}\" title=\"${linkTitle}\">${titleMsg}</a>" />
			</c:when>
			<c:otherwise>
				<c:set var="pathElement" value="${titleMsg}" />
			</c:otherwise>
		</c:choose>
		<c:set var="path" value="${path}${pathElement}" />
		<c:if test="${!listStatus.last}">
			<c:set var="path" value="${path}&nbsp;&gt;&nbsp;" />
		</c:if>
	</atleap:iterator>
</c:if>
<bean:size id="menuItemsSize" collection="${requestScope.menuItemsList}" />
<atleap:grid name="menuItemGrid">
	<atleap:messages property="menuItemNotFound" />
	<atleap:messages property="menuItemCannotDelete" />
    <atleap:message key="core.menuItem.errors.nothingChecked" var="errorMessage" />
    <atleap:form action="core/menuItem/processItemSet" method="POST" onsubmit="return hasCheckedBox(this, 'toggleAll', &#039;${errorMessage}&#039;)">
        <html:hidden property="ownerId" value="${requestScope.ownerId}" />
        <html:hidden property="multipleOperation" value="" />
        <table border="0" cellpadding="0" cellspacing="0" class="grid">
            <thead>
                <c:if test="${!empty path}">
                    <tr>
                        <th colspan="${infoCells + constantButtonCells + additionalCells}">
                            ${path}
                        </th>
                    </tr>
                </c:if>
                <tr>
                    <c:if test="${!isInRoot}">
					    <th width="20" align="center" class="checkbox">
        			        <input type="checkbox" id="toggleAll" onclick="toggleAllCheckBoxes(this.form, this.id, null);" />
                        </th>
                    </c:if>
                    <th>
                        <atleap:message key="core.menuItem.form.title" />
                    </th>
                    <c:if test="${isInRoot}">
                        <th>
                            <atleap:message key="core.menuItem.form.identifier" />
                        </th>
                    </c:if>
                    <c:if test="${!isInRoot}">
                        <th>
                            <atleap:message key="core.menuItem.form.location" />
                        </th>
                    </c:if>
                    <th>
                        <atleap:message key="core.menuItem.form.visibility" />
                    </th>
                    <th>
                        <atleap:message key="core.menuItem.form.roles" />
                    </th>
                    <c:if test="${constantButtonCells + additionalCells > 0}">
                        <th colspan="${constantButtonCells + additionalCells}">
                            <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/spacer.gif" />" border="0"  />
                        </th>
                    </c:if>
                </tr>
            </thead>
            <tbody>
                <c:if test="${!isInRoot}">
                    <atleap:rewriteUrl action="core/menuItem/list?showParent=true&ownerId=${requestScope.ownerId}" transaction="false" var="defaultUrl">
                    </atleap:rewriteUrl>
                    <tr class="evenRow" onclick="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);">
                        <td colspan="${infoCells + constantButtonCells + additionalCells}">
                            <atleap:message key="core.menuItem.form.upOneLevel" var="upOneLevelMessage" />
                            <atleap:link action="core/menuItem/list?showParent=true&ownerId=${requestScope.ownerId}" transaction="false" title="${upOneLevelMessage}">
                                ..
                            </atleap:link>
                        </td>
                    </tr>
                </c:if>
                <atleap:contextMenu var="MIMenuId">
                    <atleap:rowsIterator collection="${requestScope.menuItemsList}" var="menuItem" oddClass="oddRow" evenClass="evenRow" indexId="index" firstRowEven="false">
                        <atleap:itemSet>
                            <atleap:rewriteUrl action="core/menuItem/list?parentItemId=${menuItem.id}&ownerId=${requestScope.ownerId}" transaction="true" var="defaultUrl">
                            </atleap:rewriteUrl>
                            <tr class="${rowClass}" oncontextmenu="return showContextMenu(${MIMenuId}, event, ${index});" onclick="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);">
                                <c:if test="${!isInRoot}">
                                    <td align="center" class="defaultCursorCell">
                                        <html:checkbox property="checkedBox(${menuItem.id})" />
                                        <html:hidden property="position(${menuItem.id})" value="${index}" />
                                    </td>
                                </c:if>
                                <td>
                                    <atleap:fieldValue valueMap="${menuItem.title}" var="titleKey" />
                                    <atleap:message key="${titleKey}" var="titleMsg" ignore="true" />
                                    <c:if test="${empty titleMsg}">
                                        <c:set var="titleMsg" value="${titleKey}" />
                                    </c:if>
                                    <atleap:message key="core.menuItem.form.openItem" var="openItemMsg" />
                                    <atleap:link action="core/menuItem/list?parentItemId=${menuItem.id}&ownerId=${requestScope.ownerId}" transaction="true" title="${openItemMsg}">
                                        ${titleMsg}
                                    </atleap:link>
                                </td>
                                <c:if test="${isInRoot}">
                                    <td>
                                        <c:out value="${menuItem.identifier}" escapeXml="true" />
                                    </td>
                                </c:if>
                                <c:if test="${!isInRoot}">
                                    <td>
                                        <c:out value="${menuItem.location}" escapeXml="true" />
                                    </td>
                                </c:if>
                                <td>
                                    <atleap:message key="core.menuItem.form.visibility.${menuItem.visibility}" />
                                </td>
                                <td><c:out value="${menuItem.rolesAsString}" escapeXml="true" /></td>
                                <c:if test="${!isInRoot && canMove}">
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:item enabled="${index > 0}">
                                            <atleap:message key="core.commons.buttons.moveUp" var="callMoveUpMsg" />
                                            <atleap:itemEnabled>
                                                <atleap:itemLink action="core/menuItem/move?id=${menuItem.id}&ownerId=${requestScope.ownerId}&index=${index}&position=${index - 1}" title="${callMoveUpMsg}" transaction="true">

                                                            <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/up.gif" />" border="0" title="${callMoveUpMsg}" alt="${callMoveUpMsg}"  align="absmiddle" />
                                                            <atleap:itemLabel>
                                                                ${callMoveUpMsg}
                                                            </atleap:itemLabel>
                                                </atleap:itemLink>
                                            </atleap:itemEnabled>
                                            <atleap:itemDisabled>
                                                <atleap:itemLink title="${callMoveUpMsg}">

                                                            <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/upDisabled.gif" />" border="0" title="${callMoveUpMsg}" alt="${callMoveUpMsg}"  align="absmiddle" />
                                                            <atleap:itemLabel>
                                                                ${callMoveUpMsg}
                                                            </atleap:itemLabel>
                                                </atleap:itemLink>
                                            </atleap:itemDisabled>
                                        </atleap:item>
                                        <atleap:item enabled="${index < menuItemsSize - 1}">
                                            <atleap:message key="core.commons.buttons.moveDown" var="callMoveDownMsg" />
                                            <atleap:itemEnabled>
                                                <atleap:itemLink action="core/menuItem/move?id=${menuItem.id}&ownerId=${requestScope.ownerId}&index=${index}&position=${index + 1}" title="${callMoveDownMsg}" transaction="true">

                                                            <img class="betweenImg" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/down.gif" />" border="0" title="${callMoveDownMsg}" alt="${callMoveDownMsg}"  align="absmiddle" />
                                                            <atleap:itemLabel>
                                                                ${callMoveDownMsg}
                                                            </atleap:itemLabel>
                                                </atleap:itemLink>
                                            </atleap:itemEnabled>
                                            <atleap:itemDisabled>
                                                <atleap:itemLink title="${callMoveDownMsg}">

                                                            <img class="betweenImg" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/downDisabled.gif" />" border="0" title="${callMoveDownMsg}" alt="${callMoveDownMsg}"  align="absmiddle" />
                                                            <atleap:itemLabel>
                                                                ${callMoveDownMsg}
                                                            </atleap:itemLabel>
                                                </atleap:itemLink>
                                            </atleap:itemDisabled>
                                        </atleap:item>
                                    </td>
                                </c:if>
                                <atleap:item includeInContextMenu="false" includeInPage="${canSwitchVisibility}">
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <c:choose>
                                                <c:when test="${menuItem.visible}">
                                                    <atleap:message key="core.menuItem.buttons.makeInvisible" var="makeInvisibleMsg" />
                                                    <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=invisible&position=${index}" title="${makeInvisibleMsg}" transaction="true">

                                                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityInvisible.gif" />" border="0" alt="${makeInvisibleMsg}" title="${makeInvisibleMsg}" align="absmiddle" />
                                                                <atleap:itemLabel>
                                                                    ${makeInvisibleMsg}
                                                                </atleap:itemLabel>
                                                    </atleap:itemLink>
                                                </c:when>
                                                <c:when test="${menuItem.invisible}">
                                                    <atleap:message key="core.menuItem.buttons.makeHeritable" var="makeHeritableMsg" />
                                                    <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=heritable&position=${index}" title="${makeHeritableMsg}" transaction="true">

                                                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityHeritable.gif" />" border="0" alt="${makeHeritableMsg}" title="${makeHeritableMsg}" align="absmiddle" />
                                                                <atleap:itemLabel>
                                                                    ${makeHeritableMsg}
                                                                </atleap:itemLabel>
                                                    </atleap:itemLink>
                                                </c:when>
                                                <c:when test="${menuItem.visibilityHeritable}">
                                                    <atleap:message key="core.menuItem.buttons.makeVisible" var="makeVisibleMsg" />
                                                    <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=visible&position=${index}" title="${makeVisibleMsg}" transaction="true">

                                                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityVisible.gif" />" border="0" alt="${makeVisibleMsg}" title="${makeVisibleMsg}" align="absmiddle" />
                                                                <atleap:itemLabel>
                                                                    ${makeVisibleMsg}
                                                                </atleap:itemLabel>
                                                    </atleap:itemLink>
                                                </c:when>
                                            </c:choose>
                                        </atleap:itemEnabled>
                                    </td>
                                </atleap:item>
                                <atleap:item includeInPage="false" includeInContextMenu="${canSwitchVisibility}">
                                    <atleap:itemEnabled>
                                        <atleap:message key="core.menuItem.form.changeVisibility" var="changeVisibilityMsg" />
                                        <atleap:itemLink title="${changeVisibilityMsg}">
                                            <table cellpadding="0" cellspasing="0" border="0" style="margin:0; padding:0; font-size: 11px; " width="100%">
                                            <tr>
                                                <td>
                                                    <atleap:itemLabel>
                                                        ${changeVisibilityMsg}
                                                    </atleap:itemLabel>
                                                </td>
                                                <td align="right">
                                                    <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/arrow_right.png" />" align="middle" border="0" alt="${changeVisibilityMsg}" title="${changeVisibilityMsg}" />
                                                </td>
                                            </tr>
                                            </table>
                                        </atleap:itemLink>
                                    </atleap:itemEnabled>
                                    <atleap:item includeInPage="false">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.hideSelected" var="makeInvisibleMsg" />
                                            <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=invisible&position=${index}" title="${makeInvisibleMsg}" transaction="true">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityInvisible.gif" />" border="0" alt="${makeInvisibleMsg}" title="${makeInvisibleMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeInvisibleMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                    <atleap:item includeInPage="false">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.showSelected" var="makeVisibleMsg" />
                                            <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=visible&position=${index}" title="${makeVisibleMsg}" transaction="true">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityVisible.gif" />" border="0" alt="${makeVisibleMsg}" title="${makeVisibleMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeVisibleMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                    <atleap:item includeInPage="false">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.inheritVisibilityForSelected" var="makeHeritableMsg" />
                                            <atleap:itemLink action="core/menuItem/switchVisibility?id=${menuItem.id}&ownerId=${requestScope.ownerId}&mode=heritable&position=${index}" title="${makeHeritableMsg}" transaction="true">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityHeritable.gif" />" border="0" alt="${makeHeritableMsg}" title="${makeHeritableMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeHeritableMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                </atleap:item>
                                <c:set var="rolesAndEditAndDeleteButtonsEnabled" value="${!menuItem.redefinition && menuItem.dynamic && menuItem.owner.id == requestScope.ownerId}" />
                                <atleap:item enabled="${rolesAndEditAndDeleteButtonsEnabled}" includeInPage="${!isInRoot && canAssignRoles}" includeInContextMenu="${!isInRoot && canAssignRoles}">
                                    <atleap:message key="core.commons.buttons.assignRoles" var="assignRolesMsg"/>
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/menuItem/callAssignRoles?ownerId=${requestScope.ownerId}" title="${assignRolesMsg}">
                                                <atleap:param name="menuItemId" value="${menuItem.id}" />

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/assign_roles.gif" />" border="0" title="${assignRolesMsg}" alt="${assignRolesMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${assignRolesMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                        <atleap:itemDisabled>
                                            <atleap:message key="core.menuItem.form.assignRolesDisabled" var="assignRolesDisabledMsg" />
                                            <atleap:itemLink title="${assignRolesDisabledMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/assign_roles_disabled.gif" />" border="0" alt="${assignRolesDisabledMsg}" title="${assignRolesDisabledMsg}"  align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${assignRolesMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemDisabled>
                                    </td>
                                </atleap:item>
                                <atleap:item enabled="${rolesAndEditAndDeleteButtonsEnabled}" includeInPage="${!isInRoot && canUpdate}" includeInContextMenu="${!isInRoot && canUpdate}">
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:message key="core.commons.buttons.callUpdate" var="callUpdateMsg" />
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/menuItem/callUpdate?id=${menuItem.id}&ownerId=${requestScope.ownerId}" title="${callUpdateMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/edit.gif" />" border="0" alt="${callUpdateMsg}" title="${callUpdateMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${callUpdateMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                        <atleap:itemDisabled>
                                            <atleap:message key="core.menuItem.form.editDisabled" var="editDisabledMsg" />
                                            <atleap:itemLink title="${editDisabledMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/editDisabled.gif" />" border="0" alt="${editDisabledMsg}" title="${editDisabledMsg}"  align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${callUpdateMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemDisabled>
                                    </td>
                                </atleap:item>
                                <atleap:item includeInContextMenu="${canView}" includeInPage="${canView}">
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.commons.buttons.view" var="viewMsg"/>
                                            <atleap:itemLink action="core/menuItem/view?id=${menuItem.id}&ownerId=${requestScope.ownerId}" title="${viewMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/view.gif" />" border="0" title="${viewMsg}" alt="${viewMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${viewMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </td>
                                </atleap:item>
                                <atleap:item enabled="${rolesAndEditAndDeleteButtonsEnabled}" includeInPage="${!isInRoot && canDelete}" includeInContextMenu="${!isInRoot && canDelete}">
                                    <atleap:message key="core.commons.buttons.delete" var="deleteTitle"/>
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/menuItem/delete?id=${menuItem.id}&ownerId=${requestScope.ownerId}" transaction="true" confirmExpression="confirmDelete();" title="${deleteTitle}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/delete.gif" />" border="0" alt="${deleteTitle}" title="${deleteTitle}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${deleteTitle}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                        <atleap:itemDisabled>
                                            <atleap:message key="core.menuItem.form.deleteDisabled" var="deleteDisabledTitle"/>
                                            <atleap:itemLink title="${deleteDisabledTitle}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/deleteDisabled.gif" />" border="0" alt="${deleteDisabledTitle}" title="${deleteDisabledTitle}"  align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${deleteTitle}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemDisabled>
                                    </td>
                                </atleap:item>
                                <atleap:item includeInPage="false" includeInContextMenu="${!isInRoot && canSwitchVisibility}">
                                    <atleap:itemEnabled>
                                        <atleap:message key="core.commons.selected" var="selectedMsg" />
                                        <atleap:itemLink title="${selectedMsg}">
                                            <table cellpadding="0" cellspasing="0" border="0" style="margin:0; padding:0; font-size: 11px; " width="100%">
                                            <tr>
                                                <td>
                                                    <atleap:itemLabel>
                                                        ${selectedMsg}
                                                    </atleap:itemLabel>
                                                </td>
                                                <td align="right">
                                                    <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/arrow_right.png" />" align="middle" border="0" alt="${selectedMsg}" title="${selectedMsg}" />
                                                </td>
                                            </tr>
                                            </table>
                                        </atleap:itemLink>
                                    </atleap:itemEnabled>
                                    <atleap:item includeInPage="false" includeInContextMenu="${!isInRoot}">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.hideSelected" var="makeInvisibleMsg" />
                                            <atleap:itemLink href="javascript:setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', 'hideSelected');submitForm('switchMenuItemSetVisibilityForm');setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', '');" title="${makeInvisibleMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityInvisible.gif" />" border="0" alt="${makeInvisibleMsg}" title="${makeInvisibleMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeInvisibleMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                    <atleap:item includeInPage="false" includeInContextMenu="${!isInRoot}">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.showSelected" var="makeVisibleMsg" />
                                            <atleap:itemLink href="javascript:setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', 'showSelected');submitForm('switchMenuItemSetVisibilityForm');setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', '');" title="${makeVisibleMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityVisible.gif" />" border="0" alt="${makeVisibleMsg}" title="${makeVisibleMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeVisibleMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                    <atleap:item includeInPage="false" includeInContextMenu="${!isInRoot}">
                                        <atleap:itemEnabled>
                                            <atleap:message key="core.menuItem.buttons.inheritVisibilityForSelected" var="makeHeritableMsg" />
                                            <atleap:itemLink href="javascript:setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', 'inheritVisibilityForSelected');submitForm('switchMenuItemSetVisibilityForm');setElementValue('switchMenuItemSetVisibilityForm', 'multipleOperation', '');" title="${makeHeritableMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/visibilityHeritable.gif" />" border="0" alt="${makeHeritableMsg}" title="${makeHeritableMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${makeHeritableMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </atleap:item>
                                </atleap:item>
                            </tr>
                        </atleap:itemSet>
                    </atleap:rowsIterator>
                </atleap:contextMenu>
                 <atleap:noRows>
                    <tr>
                        <td class="tfoot" colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
                           <em><atleap:message key="core.commons.nothingToShow"/></em>
                        </td>
                    </tr>
                 </atleap:noRows>
            </tbody>
            <c:if test="${!isInRoot && canSwitchVisibility}">
                <tfoot>
                    <tr>
                        <td></td>
                        <td colspan="4" align="left">
                            <table width="100%" class="gridSubFooter" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <atleap:message key="core.commons.selected" />
                                    </td>
                                    <td>
                                        <atleap:submit property="hideSelected" styleClass="button" style="margin: 5px 10px 5px 0px;" disabled="${multipleDisabled}">
                                            <atleap:message key="core.menuItem.buttons.hideSelected" />
                                        </atleap:submit>
                                    </td>
                                    <td>
                                        <atleap:submit property="showSelected" styleClass="button" style="margin: 5px 10px 5px 0px" disabled="${multipleDisabled}">
                                            <atleap:message key="core.menuItem.buttons.showSelected" />
                                        </atleap:submit>
                                    </td>
                                    <td align="left" >
                                        <atleap:submit property="inheritVisibilityForSelected" styleClass="button" style="margin: 5px 5px 5px 0px; width: 180px;" disabled="${multipleDisabled}">
                                            <atleap:message key="core.menuItem.buttons.inheritVisibilityForSelected" />
                                        </atleap:submit>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <c:if test="${constantButtonCells + additionalCells > 0}">
                            <td colspan="${constantButtonCells + additionalCells}">
                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/spacer.gif" />" border="0"  />
                            </td>
                        </c:if>
                    </tr>
                </tfoot>
            </c:if>
        </table>
    </atleap:form>
</atleap:grid>
<c:if test="${!isInRoot}">
    <atleap:isUserInRole roles="core-menuItem-create">
        <atleap:form action="core/menuItem/callCreate" method="GET" validateOnSubmit="false">
            <html:hidden property="ownerId" value="${requestScope.ownerId}" />
            <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.create" /></atleap:submit>
        </atleap:form>
    </atleap:isUserInRole>
</c:if>
